package com.woniuxy.interceptor;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

public class MyHandlerInterceptor2 implements HandlerInterceptor {
    /**
     * 未来学习shiro的时候 会使用这个方法，来进行跨域处理！
     * @param request
     * @param response
     * @param handler
     * @return
     * @throws Exception
     */
    @Override
    public boolean preHandle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Object handler) throws Exception {
        //预处理  它是最重要的 它如果返回是false，则不允许进入到controller！
        System.out.println("MyHandlerInterceptor2.preHandle：预处理，return返回true才会进入到controller！");
        return true;
    }
    /**
     *
     * @param request
     * @param response
     * @param handler
     * @param modelAndView
     * @throws Exception
     */
    @Override
    public void postHandle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        System.out.println("MyHandlerInterceptor2.postHandle：后处理！controller执行完成后，将会跳转到jsp页面！");
    }

    @Override
    public void afterCompletion(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Object handler, Exception ex) throws Exception {
        System.out.println("MyHandlerInterceptor2.afterCompletion,在jsp访问成功后处理！");
    }
}
